<?php
    if (estConnecte()) {
        $identifiant = $_SESSION['identifiant'];
    } else {$identifiant = "";}
    if(isset($_GET["id"])) {$ligne = $_GET["id"];} else{$ligne = "";}
    if(isset($_GET["table"])) {$table = $_GET["table"];} else{$table = "";}
?>
<div class="container basPage">
    <ul class="nav nav-pills" id="CV">
      <li class="active">
        <a name="experience_prof">Expérience Professionnelle</a>
      </li>
      <li><a name="formation">Formation</a></li>
      <li><a name="informatique">Informatique</a></li>
      <li><a name="interet">Centre d'intérêt</a></li>
      <li><a name="langue">Langue</a></li>
      <li><a name="photo">Photo</a></li>
      <li><a name="exporterPDF">Exportation du CV</a></li>
    </ul>
    <div id="val"></div>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        $("a").click(function(){
           var onglet = $(this).attr("name");
           if(onglet === "exporterPDF") {
               var identifiant = "<?php echo $identifiant; ?>";
               var ligne = "<?php echo $ligne; ?>";
//               location.href = "vues/v_exporterPDFCV.php";
               location.href = "vues/v_exporterPDFCV.php?id="+identifiant+"&ligne="+ligne;

           } else {
                var request = $.ajax({
                     type: "POST",
                     url: './vues/v_'+onglet+'CV.php',
                     data: { id: "<?php echo $identifiant; ?>", ligne: "<?php echo $ligne; ?>"}
                });
                request.done(function(resultat) {
                     $("#val").html(resultat);
                     $("#CV li.active").each(function (i, elt) {
                         $(this).removeClass('active');
                     });
                     $("#CV li a[name="+onglet+"]").parent().addClass('active');
                });
                request.fail(function(resultat) {
     //                alert( "You");
                });
           }
        });
            
<?php if($table == "") {
        echo '$("a[name=experience_prof]").trigger("click")';
    } 
    else {
        echo '$("a[name='.$table.']").trigger("click")';
    }
?>
        
        
        
    });
</script>


